package com.neutech.demo.day04;

import java.util.Arrays;

public class Sort {
    public static void main(String[] args) {
        int[] arr = {5,8,9,4,6,2,3,7};
//        sortM(arr);
//        System.out.println(Arrays.toString(arr));
        double sum = sum(100);
        System.out.println(sum);

    }
    //选择
    public static int[] sort(int[] arr1){
        for (int i = 0; i <arr1.length -1; i++) {
            for (int j = i + 1; j <arr1.length ; j++) {
                if (arr1[i] > arr1[j]){
                    int temp = arr1[j];
                    arr1[j] = arr1[i];
                    arr1[i] = temp;
                }
            }
        }
        return  arr1;
    }
    //冒泡排序
    public static int[] sortM(int[] arr2){
        for (int i = 0; i <arr2.length-1 ; i++) {
            for (int j = 0; j < arr2.length - i - 1 ; j++) {
                if (arr2[j] > arr2[j+1]){
                    int temp = arr2[j];
                    arr2[j] = arr2[j+1];
                    arr2[j+1] = temp;
                }
            }
        }
        return arr2;
    }

    //前100项和
    public static double sum(int n){
        if (n == 1){
            return 1;
        }
        return 1.0/n + sum(n-1);
    }
}
